package reviewQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method "POST"
        url "api/v2/review/logicQuizzes"
        headers {
            contentType(applicationJsonUtf8())
            header("id", 21)
        }
        body("""
            {
            "tutorId":1,
            "sectionId":1,
            "taskId":1,
            "quizId":1,
            "assignmentId":1,
            "excellence":true,
            "supplement":"11"
            }
        """)
        bodyMatchers {
            jsonPath('$.tutorId', byRegex(number()))
            jsonPath('$.sectionId', byRegex(number()))
            jsonPath('$.taskId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.excellence', byRegex(anyBoolean()))
            jsonPath('$.supplement', byRegex(nonEmpty()))
        }
    }
    response {
        status 201
        body("""
            {
            "tutorId":1,
            "sectionId":1,
            "taskId":1,
            "quizId":1,
            "assignmentId":1,
            "status":"已完成",
            "excellence":true,
            "supplement":"11"
            }
        """)
        bodyMatchers {
            jsonPath('$.tutorId', byRegex(number()))
            jsonPath('$.sectionId', byRegex(number()))
            jsonPath('$.taskId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.excellence', byRegex(anyBoolean()))
            jsonPath('$.status', byRegex(nonEmpty()))
            jsonPath('$.supplement', byRegex(nonEmpty()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}